<script lang="ts" setup>
import { defineEmits, defineProps, onMounted, ref } from 'vue';

withDefaults(
  defineProps<{
    open?: Boolean;
    userId: string;
  }>(),
  {
    open: false, // 默认值
  },
);
const emit = defineEmits(['close']);
const _selectedRowKeys = ref<string[]>([]);
const loading = ref<boolean>(false);

const dataSource = ref([
  {
    clientId: 1,
    clientName: '香奈儿',
  },
]);
const columns = ref([
  {
    title: '客户名称',
    dataIndex: 'clientName',
    key: 'clientName',
    align: 'center',
  },
]);
const onSelectChange = (selectedRowKeys: string[]) => {
  // console.log('selectedRowKeys changed:', selectedRowKeys);
  _selectedRowKeys.value = selectedRowKeys;
};

const onClose = () => {
  emit('close');
};

onMounted(() => {
  list();
});

const list = async () => {};
</script>
<template>
  <a-modal
    :visible="open"
    title="关联客户"
    width="50%"
    @ok="onClose"
    @cancel="onClose"
  >
    <a-table
      :row-selection="{
        selectedRowKeys: _selectedRowKeys,
        onChange: onSelectChange,
      }"
      :columns="columns"
      :data-source="dataSource"
    />
  </a-modal>
</template>
<style scoped></style>
